﻿
using System;
using System.Data;
namespace ZHDJ.MobileInterface
{
    public partial class GetInformationCount : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象
            InformationCountOutParam result = new InformationCountOutParam();
            InformationCountInParam param = new InformationCountInParam();
            string logMsg = "";

            try
            {
                param = inParam as InformationCountInParam;

                DataSet ds = InterfaceHelper.GetInformationCount();

                if (ds != null && ds.Tables.Count == 5)
                {
                    //通知公告数量
                    result.data.new_notice_count = ds.Tables[0].Rows[0][0].ToString();

                    //热点新闻最新资讯数量
                    result.data.hotnews_count = ds.Tables[1].Rows[0][0].ToString();

                    //学习十八大资讯数量
                    result.data.shibada_count = ds.Tables[2].Rows[0][0].ToString();

                    //党员先锋最新资讯数量
                    result.data.vanguard_count = ds.Tables[3].Rows[0][0].ToString();

                    //组织风采资讯数量 
                    result.data.branch_mien_count = ds.Tables[4].Rows[0][0].ToString();
                }
                
                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员";
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode +"-GetInformationCount", "", logMsg);
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<InformationCountInParam, InformationCountOutParam>();
            else
                SafeProcessRequest<InformationCountInParam, InformationCountOutParam>();
        }
    }

    #region 请求参数
    public class InformationCountInParam
    { 
    }
    #endregion

    #region 结果参数
    public class InformationCountOutParam
    {
        public InformationCountOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new InformationCountData();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 结果
        /// </summary>
        public InformationCountData data
        { get; set; } 
    }

    public class InformationCountData
    { 
        /// <summary>
        /// 通知公告数量
        /// </summary>
        public string new_notice_count
        { get; set; }

        /// <summary>
        /// 热点新闻最新资讯数量
        /// </summary>
        public string hotnews_count
        { get; set; }

        /// <summary>
        /// 学习十八大资讯数量
        /// </summary>
        public string shibada_count
        { get; set; }

        /// <summary>
        /// 组织风采资讯数量
        /// </summary>
        public string branch_mien_count
        { get; set; }

        /// <summary>
        /// 党员先锋最新资讯数量
        /// </summary>
        public string vanguard_count
        { get; set; } 
    }
    #endregion
}